<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<html>
	<head>
		<title>A Free Online Rental Application</title>
		<script LANGUAGE="JavaScript">
	function validatePropertyForm() {
		if (document.propertyForm.name.value == "") {
			alert("Property Name should n't be left blank");
			document.propertyForm.name.focus();
			return false;
		} else if (document.propertyForm.rent.value == "") {
			alert("Rent should n't be left blank");
			document.propertyForm.rent.focus();
			return false;
		} else if (document.propertyForm.zipCode.value == "") {
			alert("ZipCode should n't be left blank");
			document.propertyForm.zipCode.focus();
			return false;
		} else if (document.propertyForm.city.value == "") {
			alert("CityName should n't be left blank");
			document.propertyForm.cityName.focus();
			return false;
		} else if (document.propertyForm.state.value == "") {
			alert("StateName should n't be left blank");
			document.propertyForm.stateName.focus();
			return false;
		} else if (document.propertyForm.noOfMembersAllowed.value == "") {
			alert("No Of Members Allowed - should n't be left blank");
			document.propertyForm.noOfMembersAllowed.focus();
			return false;
		} else if (document.propertyForm.maintenanceCost.value == "") {
			alert("Maintenance Cost should n't be left blank");
			document.propertyForm.maintenanceCost.focus();
			return false;
		} else if (document.propertyForm.message.value == "") {
			alert("Message should n't be left blank");
			document.propertyForm.message.focus();
			return false;
		} else {
			document.propertyForm.action = "home.do?dispatch=publish";
			document.propertyForm.submit();
		}
	}
	function backToSearch() {
		document.propertyForm.action = "search.do?dispatch=search";
		document.propertyForm.submit();
	}
	function getStateCities(){
	var stateId = document.getElementById('state').value;
	document.propertyForm.action = "home.do?dispatch=getCities&stateId="+stateId;
		document.propertyForm.submit();
	}
</script>
	</head>
	<body>
		<table width="100%">
			<tr>
				<td align="center" >
					<h4>
						<bean:message key="rental.m1" />
					</h4>
				</td>
				<td align="center">
					<a href="signout.do?dispatch=signout"> <bean:message
							key="rental.signout" /> </a>
				</td>
			</tr>
		</table>

	</body>
	<CENTER>
		<h2>
			<bean:message key="rental.m3" />
		</h2>
		<html:errors />
		<table>
			<html:form action="home">
				<tr>
					<td>
						<bean:message key="property.name" />
						*
					</td>
					<td>
						<html:text property="name" />
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.rent" />
						*
					</td>
					<td>
						<html:text property="rent" />
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.stateName" />
						*
					</td>
					<td>
						<html:select property="state" onchange="getStateCities()">
							<html:optionsCollection name="states" label="stateName"
								value="statId" />
						</html:select>
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.cityName" />
						*
					</td>
					<td>
						<html:select property="city">
							<html:optionsCollection name="stateCities" label="cityName"
								value="cityId" />
						</html:select>
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.zipCode" />
						*
					</td>
					<td>
						<html:text property="zipCode" />
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.petsAllowed" />
						*
					</td>
					<td>
						<html:radio property="petsAllowed" value="true" >
							<bean:message key="property.yes" />
						</html:radio>
						<html:radio property="petsAllowed" value="false">
							<bean:message key="property.no" />
						</html:radio>
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.noOfMembersAllowed" />
						*
					</td>
					<td>
						<html:text property="noOfMembersAllowed" />
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.maintenanceCost" />
						*
					</td>
					<td>
						<html:text property="maintenanceCost" />
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.rentNegotiable" />
						*
					</td>
					<td>
						<html:radio property="rentNegotiable" value="true">
							<bean:message key="property.yes" />
						</html:radio>
						<html:radio property="rentNegotiable" value="false">
							<bean:message key="property.no" />
						</html:radio>
					</td>
				</tr>
				<tr>
					<td>
						<bean:message key="property.message" />
						*
					</td>
					<td>
						<html:textarea cols="50" rows="3" property="message" />
					</td>
				</tr>
				<tr>
					<td>
						<input type="button" value="  <<  Back to Search"
							onclick="backToSearch()" />
					</td>
					<td>
						<input type="button" value="Publish Above property >> "
							onclick="validatePropertyForm()" />
					</td>
				</tr>
			</html:form>
		</table>
	</CENTER>
</html>
